finding the terms of sequence